package com.ym.b2b.provider.dao.impl;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;

import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Repository;

import com.ym.b2b.commons.dao.BaseDao;
import com.ym.b2b.provider.dao.EmCProviderDAO;
import com.ym.b2b.provider.sqlbean.EmCProvider;
import com.zc.commons.base.Page;

@Repository
public class EmCProviderDAOImpl extends BaseDao implements EmCProviderDAO {

    @Override
    public Long searchPageEmCProviderNum(EmCProvider emcprovider) throws SQLException {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("map", emcprovider);
        return (Long) listNum("EM_C_PROVIDER.searchPageEmCProviderNum", map);
    }

    @Override
    public Page searchPageEmCProvider(EmCProvider emcprovider, Page<EmCProvider> page) throws SQLException {
        page.setTotalRow(searchPageEmCProviderNum(emcprovider));
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("map", emcprovider);
        map.put("startrow", page.getStartRow());
        map.put("pagesize", page.getPageSize());
        map.put("pageable", page.getPageable());
        page.setRows(list("EM_C_PROVIDER.searchPageEmCProvider", map));
        return page;
    }

    @Override
    public void insertEmCProvider(EmCProvider emCProvider) throws SQLException {
        insert("EM_C_PROVIDER.insertEmCProvider", emCProvider);
    }

    /*
     * 查询明细
     */
    @Override
    public EmCProvider showEmCProviderDetail(EmCProvider emCProvider) throws DataAccessException {
        return (EmCProvider) find("EM_C_PROVIDER.showEmCProviderDetail", emCProvider);
    }

    /*
     * 更新
     */
    @Override
    public void updateEmCProvider(EmCProvider emCProvider) throws DataAccessException {
        update("EM_C_PROVIDER.updateEmCProvider", emCProvider);
    }

    /*
     * 删除
     */
    @Override
    public void deleteEmCProvider(EmCProvider emCProvider) throws DataAccessException {
        // System.out.println("----供应商ID:" + emCProvider.getProviderId());
        delete("EM_C_PROVIDER.deleteEmCProvider", emCProvider);
    }

    @Override
    public void deleteMultipleEmCProviders(String providerIdList) {
        delete("EM_C_PROVIDER.deleteMultipleEmCProviders", providerIdList);
    }

    /*
     * (non-Javadoc)
     * @see com.ym.b2b.provider.dao.EmCProviderDAO#editMultipleEmCProvidersStatus(java.lang.String)
     */
    @Override
    public void editMultipleEmCProvidersStatus(String providerIdList) {
        update("EM_C_PROVIDER.updateMultipleEmCProviderStatus", providerIdList);
    }

}
